
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Demo31 {
    public static void main(String[] args) throws InterruptedException {
        //创建线程池
        ExecutorService pool = Executors.newFixedThreadPool(4);
        CountDownLatch countDownLatch = new CountDownLatch(10);
        Thread t = new Thread(() -> {
            for (int i = 0; i < 10; i++) {
                int id = i;
                pool.submit(() -> {
                    System.out.println("线程名字" + Thread.currentThread() + "," + "执行任务" + id);
                });
                try {
                    Thread.sleep(3000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                countDownLatch.countDown();
            }
        });
        t.start();
        countDownLatch.await();
    }

//        CountDownLatch latch = new CountDownLatch(20);20个下载次数，问题是怎么区分 线程、线程池、和 任务内容
//        for (int i = 0; i <4 ; i++) {                     线程池 直接创建就行
//            Thread thread = new Thread(()->{
//                System.out.println();
//            });
//        }

}
